<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Ven_contact extends Page
{
       public $JTJavaScript2 = null;
       public $hidden_vend = null;
       public $JTJavaScript1 = null;
       public $JTVendContactList = null;
       public $JTSiteTheme1 = null;
       function Ven_contactCreate($sender, $params)
       {
       $vend_id = $_GET['vendor_id'];
       $this->hidden_vend->setValue($vend_id);

       }



       function JTVendContactListShow($sender, $params)
       {
       $vend = $this->hidden_vend->getValue();
       if($vend==0)
       {
       $query1 = "select * from vendor_contact where company_id='".$_SESSION['company_id']."' and vendor_num='' and edit_who='".$_SESSION['username']."'";
       }

       if($vend!=0)
       {
       $query1 = "select * from vendor_contact where company_id='".$_SESSION['company_id']."' and vendor_num='".$this->hidden_vend->getValue()."' and edit_who='".$_SESSION['username']."'";
       }

       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {
            $contact_num = $row['contact_num'];
            $vendor = "<a href=vendor_edit.php?vend_id=".$vendor_id.">".$row['lname'].','.$row['fname']."</a>";
            $tools = "<img onclick=js_deleteContact('".$contact_num."'); src='image/delete.png' title='delete' style='cursor:pointer'>";
            //$vend_name = "<div onclick=window.open('vendor_contact_edit.php?contact=".$contact_num."')>".$row['lname'].','.$row['fname']."<div/>";
            //$vend_name = "<a href='vendor_contact_edit.php?contact=".$contact_num."' target='_blank'>".$row['lname'].','.$row['fname']."</a>";

            $vend_name = "<a href='' onClick=editContact('".$contact_num."') title='Edit Contact'>".$row['lname'].','.$row['fname']."</a>";


            $arr[] = array(
                        'Name' => $vend_name,
                        'Designation' => $row['designation'],
                        'Phone' => $row['phone'],
                        'Mobile' => $row['mobile'],
                        'Email' => $row['email'],
                        'Tools' => $tools
                        );


          }

            $this->JTVendContactList->setCellData($arr);


       }

}

global $application;

global $Ven_contact;

//Creates the form
$Ven_contact=new Ven_contact($application);

//Read from resource file
$Ven_contact->loadResource(__FILE__);

//Shows the form
$Ven_contact->show();

?>